<template>
<div>
    <div>
    <el-card class="box-card" style="margin-left: auto; margin-right: auto;">
        <div slot="header" class="clearfix">
            <span>投诉管理</span>
        </div>
        <div>
          <span style=" float: left; margin-top: 10px;">投诉类型</span>
          <el-select v-model="complaintsTypeId" placeholder="请选择" style="float: left; width: 20%; margin-bottom: 20px;  margin-left: 20px;">
            <el-option
                v-for="item in options"
                :key="item.complaintsTypeId"
                :label="item.type"
                :value="item.complaintsTypeId">
            </el-option>
        </el-select>
          <el-button type="primary" icon="el-icon-circle-plus" style="float: right; " @click="complainSelect(complaintsTypeId)">查询</el-button>
        </div>
    </el-card>
    <el-card class="box-card" style="margin-left: auto; margin-right: auto;">
        <div slot="header" class="clearfix">
            <span>投诉列表</span>
        </div>
        <div>
            <el-table
            :data="InfoList"
            style="width: 100%">
            <el-table-column
                prop="type"
                label="投诉类型"
                width="150">
            </el-table-column>
            <el-table-column
                prop="problemDescription"
                label="问题描述"
                width="150">
            </el-table-column>
            <el-table-column
                prop="processingState"
                label="处理状态"
                width="150">
            </el-table-column>
            <el-table-column
                prop="theComplainant"
                label="投诉人ID"
                width="150">
            </el-table-column>
            <el-table-column
                prop="processingResults"
                label="投诉结果"
                width="150">
            </el-table-column>
            <el-table-column
                prop="userName"
                label="处理人姓名"
                width="180">
            </el-table-column>
            <el-table-column
                prop="createTime"
                label="创建时间"
                width="150">
            </el-table-column>
            <el-table-column
                fixed="right"
                label="操作"
                width="200">
                <template slot-scope="scope">
                    <!-- <el-button  type="text" size="small">审核</el-button> -->
                    <el-button  type="text" size="small" @click="Update(scope.row),dialogFormVisible= true">显示详情</el-button>
                </template>
            </el-table-column>
            </el-table>
            <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="currentPage"
              :page-sizes="[2, 4, 6, 8]"
              :page-size="2"
              layout="total, sizes, prev, pager, next, jumper"
              :total="pageTotal">
            </el-pagination>
        </div>
    </el-card>
  </div>
  <div>
        <el-dialog title="详细信息" :visible.sync="dialogFormVisible">
            <el-form :model="ruleForm" status-icon  ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="投诉类型" >
                <el-input v-model="ruleForm.type" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="问题描述" >
                <el-input v-model="ruleForm.problemDescription" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="处理状态" >
                <el-input v-model="ruleForm.processingState" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="投诉人ID" >
                <el-input v-model="ruleForm.theComplainant" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="投诉结果" >
                <el-input v-model="ruleForm.processingResults" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="投诉人姓名" >
                <el-input v-model="ruleForm.userName" :disabled="true"></el-input>
                </el-form-item>
                <el-form-item label="创建时间" >
                <el-input v-model="ruleForm.createTime" :disabled="true"></el-input>
                </el-form-item>
            </el-form>
        </el-dialog>
  </div>
</div>
</template>

<script>
export default {
  data() {
        return {
          tableData: [],
          InfoList:[],
          input: '',
          complaintsTypeId:'',
          dialogFormVisible: false,
          dialogFormVisible1: false,
          ruleForm:{
            complaintsId:'',
            complaintsTypeId:'',
            problemDescription:'',
            theComplainant:'',
            processingState:'',
            processingResults:'',
            userId:'',
            createTime:'',
            updateTime:'',
            type:'',
            userName:'',
          },
          pageTotal: 0, // 总数
          pageNum: 1, // 页数
          pageSize: 2, // 条数
          currentPage: 1, // 分页中当前页变量
          options: [
            {complaintsTypeId:'1',
            type:'物业服务'},
            {complaintsTypeId:'2',
            type:'公共基础设施'}
          ],
          value: '',
          visitorsName:'',
          complaintsTypeId:'',
        }
    },
    methods: {
        tousuSelect(){
            this.$axios.get("http://localhost:9000/serverchy/Complain/tousuSelect").then(response=>{
                  this.options=response.data.data.list
              }
              ).catch(e=>{
              })
          },
        Update(data){
              this.ruleForm.type=data.type
              this.ruleForm.problemDescription=data.problemDescription
              this.ruleForm.visitorsName= data.visitorsName
              this.ruleForm.theComplainant= data.theComplainant
              this.ruleForm.processingState=data.processingState
              this.ruleForm.processingResults=data.processingResults
              this.ruleForm.communityName=data.communityName
              this.ruleForm.createTime=data.createTime
              this.ruleForm.userName=data.userName
          },
        handleSizeChange(val) {
          this.pageSize = val
          this.complainSelect()
        },
        handleCurrentChange(val) {
          this.pageNum =val
          this.complainSelect()
        },
        complainSelect() {
            // this.tousuSelect();
            // 获取所有用户信息
            this.$axios.get("http://localhost:9000/serverchy/Complain/complainSelect",{
              params:{
                pageNum: this.pageNum,
                pageSize: this.pageSize,
                complaintsTypeId:this.complaintsTypeId
              }
          }).then((res) => {
              this.InfoList = res.data.list
              this.pageTotal = res.data.total
            });
        },
    },
    mounted() {
      this.complainSelect()
      // this.tousuSelect()
    }
}
</script>

<style>
    .text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }

  .box-card {
    width: 1136px;
  }
</style>